﻿using System;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Media.Animation;
using WoodRobotics.Weather.ViewModel;

namespace WoodRobotics.Weather
{
    
    public partial class MainWindow : Window
    {
        
        #region Constructor
        public MainWindow()
        {
            InitializeComponent();
        }
        #endregion
        
        #region Events
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            
            this.Left = Screen.PrimaryScreen.WorkingArea.Width - this.Width + 5;
            this.Top = Screen.PrimaryScreen.WorkingArea.Height - this.Height + 15;
            
            this.Visibility = System.Windows.Visibility.Hidden;
            
            ((Storyboard)this.Resources["FadeOut"]).Begin();
            ((Storyboard)this.Resources["FadeOut"]).Completed += new EventHandler(FadeOut_Completed);
            
            WPFnotifyIcon1.TaskTrayVisible = true;
            
        }
        
        private void FadeOut_Completed(object sender, EventArgs e)
        {
            this.Visibility = System.Windows.Visibility.Hidden;
        }
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            WPFnotifyIcon1.TaskTrayVisible = false;
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ((Storyboard)this.Resources["FadeOut"]).Begin();
        }
        private void WPFnotifyIcon1_Click(object sender, EventArgs e)
        {
            if (this.Visibility == System.Windows.Visibility.Visible)
                ((Storyboard)this.Resources["FadeOut"]).Begin();
            else
            {
                this.Visibility = System.Windows.Visibility.Visible;
                ((Storyboard)this.Resources["FadeIn"]).Begin();
            }
        }
        
        private void AddEventCMD_Click(object sender, RoutedEventArgs e)
        {
            ((CurrentWeather)MainGrid.DataContext).Astronomy.AddEvent();
        }
        private void SaveEventsCMD_Click(object sender, RoutedEventArgs e)
        {
            ((CurrentWeather)MainGrid.DataContext).Astronomy.Serialize();
        }
        #endregion
        
    }
    
}